package diploma.kisel.modelas.validation;

public class Validation {
	
	public static boolean isNumber(String text) {
		try {
			int number=Integer.parseInt(text);
		} catch (NumberFormatException e) {
			return false;
		}
		return true;
	}
	
	public static boolean isEmpty(String text) {
		if (text.equals(""))
			return true;
		else
			return false;
	}
	
	public static boolean isLengthBetween(String text, int min, int max) {
		if (text.length()>=min && text.length()<=max)
			return true;
		else
			return false;
					
	}
	
	public static boolean isDate(String text) {
		if (text.matches("\\d\\d\\-\\d\\d\\-\\d\\d\\d\\d"))
			return true;
		else return false;
	
	}
	
	public static String reformatDateString(String date) {
		String [] array = date.split("-");
		String resultDate = array[2]+"-"+array[1]+"-"+array[0];
		return resultDate;
	}

}
